﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DGen.Text
{
	/// <summary>
	/// Work in progress. Returns similarity between two text strings. Doesn't work at time of writing (2010-01-24)
	/// </summary>
    public class Similarity
	{

        /// <summary>
        /// Simple string comparison comparison.
        /// </summary>
        /// <param name="x">first string</param>
        /// <param name="y">second string</param>
        /// <returns></returns>
        public static double Simple(string x, string y)
        {
            double possibleScore = 100000;
            x=x.ToUpper();
            y=y.ToUpper();

            double scorePerCharacter = possibleScore/(x.Length+y.Length);
            double runningScore = 0;
            for (int i = 0; i < Math.Min(x.Length,y.Length); i++)
            {
                if (x[i] == y[i])
                {
                    runningScore = runningScore + scorePerCharacter;
                }
            }
            return runningScore;
        }







	}
}
